<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-with,initial-scale=1.0">
<title>显示隐藏</title>
<script src="https://unpkg.com/vue@next"></script>
 
</head>
<body>
<div id="root">
 
</div>
 
<script>
Vue.createApp({
    data(){
        return{
            show:true
        }
    },
        methods:{
            handleBtnClick(){
                this.show=!this.show;
            }
        },
        template:`
            <div>
            <span v-if="show">Hello world</span>
            <button v-on:click="handleBtnClick">显示/隐藏</button>
            </div>
        `

}).mount('#root')
</script>
</body>
</html>